home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Format CD 37
/
Amiga Format CD37 (1999-02-16)(Future Publishing)(GB)(Track 1 of 3)[!][issue 1999-03].iso
/
-screenplay-
/
otherstuff
/
petro
/
petro.asc
< prev
next >
Wrap
Text File
|
1999-01-04
|
5KB
|
159 lines
; Petro - public domain by James L Boyd
; do what you like with it ;)
; IMPORTANT - type Blitzlibs:amigalibs.res into the Resident box
; in Compiler Options
; note the distribution version of the executable is packed
; with StoneCracker (recommended :)
; don't forget to turn the Debugger off when you make the executable
v$="$VER: Petro 1.0 (20-9-1998) James L Boyd"
; version number (appears in WBVersion,etc)
WBStartup ; start from a Workbench icon
FindScreen 0,"Workbench Screen" ; find the WB screen
NoCli ; no default cli
x.w=0 ; default window position
y.w=0 ; ditto
offset.b=4 ; default for weird shape positioning
If GetIconObject("progdir:Petro") ; read icon's tooltypes
title$=FindToolValue("TITLE")
gadgettext$=FindToolValue("GADGET_TEXT")
petrogfx$=FindToolValue("PETRO_GFX") ; "petro_gfx.iff"
petrosnd$=FindToolValue("PETRO_SND") ; "petro_snd.iff"
x=Val(FindToolValue("X"))
y=Val(FindToolValue("Y"))
offset=Val(FindToolValue("OFFSET"))
FreeIconObject ; IMPORTANT! free the icon
EndIf
;set defaults in case of tooltype errors
If title$="" Then title$="Petro"
If gadgettext$="" Then gadgettext$="Talk to me!"
If petrogfx$="" OR Exists(petrogfx$)=0 Then petrogfx$="progdir:snd+gfx/petro_gfx.iff"
If petrosnd$="" OR Exists(petrosnd$)=0 Then petrosnd$="progdir:snd+gfx/petro_snd.iff"
#SIGBREAKF_CTRL_C=1 ASL 12 ; to enable trapping of CTRL-C messages later
;get some info (used to get WB font height) - don't understand this ;)
*SC.Screen=Peek.l(Addr Screen(0))
*SCFONT.TextAttr=*SC.Screen\Font
*USEDFONT.TextAttr=*SCFONT.TextAttr
HEIGHT_WBFONT=(*SCFONT.TextAttr\ta_YSize)
; gadtools menus (automatic spacing,etc)
GTMenuTitle 0,0,"Project"
GTMenuItem 0,0,0,0,"Snapshot window","S"
GTMenuItem 0,0,0,1,"About","A"
GTMenuItem 0,0,0,2,"Quit","Q"
; check the files are there
If Exists(petrogfx$)=0 OR Exists(petrosnd$)=0
;Request "","INFO : "+petrogfx$+"+"+petrosnd$,"OK"
Request "Petro","ERROR - Can't find Petro's files...","Oh...":Goto quit
EndIf
; error trap if wrong type of file,or something weird happens ;)
; start of error trapping code
SetErr ; do whatever's between here and End SetErr if an error occurs...
Request "Petro","Ooh,bad error - quitting!||Try checking your tooltypes and sound/graphics files!","Uh,right...":End
End SetErr
LoadShape 0,petrogfx$
LoadSound 0,petrosnd$
ClrErr
;end of error trapping code (so it includes the loadshape/sound part)
; about requester string
req$="P e t r o||This is Petro Tyschtschenko,|President of Amiga International...||All Hail Petro!"
req$=req$+"||Written by a bored James L Boyd,|19 September 1998 ;)"
req$=Replace$(req$,"|",Chr$(10)) ; replace |'s with chr$(10) for RTEZRequest (normal Request uses |'s)
tryagain ; program loops back here if window fails to open
If tried.b<2 ; if window failed to open
If tried=1 ; if failed once
Request "Petro","Window wouldn't fit on screen!|Resetting to X=0 and Y=0,and updating tooltypes!","Right..."
x=0:y=0:Gosub snap
EndIf
If Window (0,x,y,ShapeWidth(0)+offset+8,HEIGHT_WBFONT+ShapeHeight(0)+28,$e,title$,1,2)=0 Then tried+1:Goto tryagain
Else Request "Petro","Can't open window - low chip memory?","Abort":Goto quit ; if window didn't open on second try
EndIf
GTButton 0,51,2,ShapeHeight(0)+2,ShapeWidth(0),20,gadgettext$,0 ; the gadget
AttachGTList 0,0 ; attach the gadget list to the window
GTSetMenu 0 ; and the menus
WBlit 0,WLeftOff+2,HEIGHT_WBFONT+4 ; blit the shape
loop ; main event loop
ev.l=Event ; get window event
VWait 5 ; delay to aid multitasking (don't need a rapid response here ;)
; check for CTRL-C message
If (SetSignal_(0,#SIGBREAKF_CTRL_C) & #SIGBREAKF_CTRL_C) ; catch CTRL-C's
Goto quit
EndIf
Select ev ; find value of ev
Case $40 ; gadget hit
Sound 0,10 ; speak,Petro!
Freq 10,127 ; - damn sound sample kept playing slow,so had to speed it up!
Case $100 ; menu hit
Select ItemHit ; find the menu item
Case $0 ; snapshot
x=WindowX:y=WindowY
Gosub snap
Case $1 ; about
lock.l=RTLockWindow(0)
rt.l=RTEZRequest ("Petro",req$,"Cool...")
RTUnlockWindow 0,lock
Case $2 ; quit
Goto quit
End Select
Case $200 ; close gadget
Goto quit
End Select ; end of main Select WaitEvent loop
Goto loop ; end of whole event loop
snap ; snapshot window
If GetIconObject("progdir:Petro") ; write tooltypes
ClearToolTypes ; clear the ones that are there
; and stick all the values back in
NewToolType "DONOTWAIT",""
NewToolType "TITLE",title$
NewToolType "GADGET_TEXT",gadgettext$
NewToolType "PETRO_GFX",petrogfx$
NewToolType "PETRO_SND",petrosnd$
NewToolType "X",Str$(x)
NewToolType "Y",Str$(y)
NewToolType "OFFSET",Str$(offset)
PutIconObject ("progdir:Petro") ; WRITE the icon (important!)
FreeIconObject ; free the icon (important!)
Else Request "Petro","Error saving tooltypes","Weird..." ; didn't work
EndIf
Return
quit
End